// process.h
// Joseph Craig, Rebecca Rush, Steven Andryzcik
// Version 6 - 12/08/2011

#ifndef PROCESS_H
#define PROCESS_H

#include "pqueue.h"

/*********************************** Macros ***********************************/
#define PCB_NAME_SIZE  32
#define PCB_STACK_SIZE 4096

#define READY 1
#define SUSPENDED 2
#define BLOCKED 3

#define SYSTEM 1
#define APPLICATION 2

#define ERR_GEN_OUTOFMEMORY   100
#define ERR_CHANGE_OF_SYSTEM_PROCESS 101

#define DISPLAY_AT_A_TIME 10

#define SYS_STACK_SIZE 4096

/*************************** Process Control Block ****************************/
struct process_control_block {
	char name[PCB_NAME_SIZE];
	int
		memory_size,
		priority,
		state,
		class;
	unsigned char
		stack_base[PCB_STACK_SIZE], 
		*stack_top,
		*execute,
		*load;
	unsigned long added;
};

typedef struct process_control_block pcb;
typedef struct process_control_block *ppcb;

/********************************** Context ***********************************/
struct _context{
	unsigned int BP, DI, SI, DS, ES;
	unsigned int DX, CX, BX, AX;
	unsigned int IP, CS, FLAGS;
};

typedef struct _context context;

/********************************** Params ***********************************/
struct _params{
	int op_code;
	int device_id;
	char *buf_addr;
	int *count_addr;
};

typedef struct _params params;


/************************ Process Function Prototypes *************************/
int empty_process_queues(int *);
int initialize_process_queues(int *);

int pcb_resume(char *);
int pcb_set_priority(char *, int);
int pcb_show(char *);
int pcb_show_blocked();
int pcb_show_ready();
int pcb_show_suspended();

ppcb pcb_allocate();
ppcb pcb_find(char *);
ppcb pcb_setup(char *, int, int);
void make_empty();
void pcb_insert(int, ppcb);
void pcb_free(ppcb);
void pcb_remove(ppcb);

#endif